/****************************************************************************/
/***                                                                      ***/
/***   (C) 2012-2014 Dierk Ohlerich et al., all rights reserved.          ***/
/***                                                                      ***/
/***   Released under BSD 2 clause license, see LICENSE.TXT               ***/
/***                                                                      ***/
/****************************************************************************/

mtrl PointSpritesShader 
{
  struct ia2vs
  {
    float3 pos : POSITION;
    float3 norm : NORMAL;
    float2 uv0 : TEXCOORD0;
  };
  struct vs2gs
  {
    float3 pos : TEXCOORD1;
  };
  struct gs2ps
  {
    float4 tpos : SV_Position;
    float2 uv0 : TEXCOORD0;
  };

  cbuffer cbvs : vs(0) : register(0)
  {
    float4 dummy;
  };
  cbuffer cbgs : gs(0) : register(0)
  {
    row_major float4x4 mat;
    float3 ttx;
    float3 tty;
  };
  
  vs hlsl5
  {
    void main(in ia2vs i,out vs2gs o)
    {
      o.pos = i.pos;
    }
  };
  gs hlsl5
  {
    [maxvertexcount(4)]
    void main(point vs2gs i[1],inout TriangleStream<gs2ps> os)
    {
      gs2ps o;
 
      o.tpos = mul(mat,float4(i[0].pos+ttx+tty,1));
      o.uv0 = float2(0,0);
      os.Append(o);
      o.tpos = mul(mat,float4(i[0].pos+ttx-tty,1));
      o.uv0 = float2(0,1);
      os.Append(o);
      o.tpos = mul(mat,float4(i[0].pos-ttx+tty,1));
      o.uv0 = float2(1,0);
      os.Append(o);
      o.tpos = mul(mat,float4(i[0].pos-ttx-tty,1));
      o.uv0 = float2(1,1);
      os.Append(o);
    }
  };
  ps hlsl5
  {
    Texture2D tex0 : register(t0);
    SamplerState sam0 : register(s0);

    void main(in gs2ps i,out float4 r:SV_Target)
    {
      r = tex0.Sample(sam0,i.uv0);
    }
  };
} 
/****************************************************************************/
